import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mediapipe_task_vision_example/page/pose_image.dart';
import 'package:mediapipe_task_vision_example/page/pose_live.dart';
import 'package:mediapipe_task_vision_example/util/utils.dart';

class PoseExample extends StatefulWidget {
  const PoseExample({super.key});

  @override
  State<PoseExample> createState() => _PoseExampleState();
}

class _PoseExampleState extends State<PoseExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text("姿势识别实例")),
        body: Container(
            child: Column(
          children: [
            ListTile(onTap: bottomDialog, title: const Text("图片")),
            // ListTile(
            //     onTap: () {
            //       Navigator.push(context, MaterialPageRoute(builder: (c) {
            //         return const PoseLiveWidget();
            //       }));
            //     },
            //     title: const Text("视频流")),
          ],
        )));
  }

  void bottomDialog() {
    showModalBottomSheet(
        context: context,
        builder: (c) {
          return Container(
              child: Column(mainAxisSize: MainAxisSize.min, children: [
            ListTile(
                onTap: () async {
                  String croppedFile = await Utils().getImgByCamera(context);
                  if (croppedFile != "") {
                    Navigator.push(context, MaterialPageRoute(builder: (c) {
                      return PoseImageWidget(croppedFile);
                    }));
                  }
                },
                title: Text("拍照")),
            ListTile(
                onTap: () async {
                  String croppedFile = await Utils().getImgByGallery(context);
                  if (croppedFile != "") {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return PoseImageWidget(croppedFile);
                    }));
                  }
                },
                title: Text("相册")),
          ]));
        });
  }

}
